<template>
    <div class="head">
        <div class="left">
            <img src="@/assets/logo.png" alt="">

        </div>
        <div class="right">
            <div class="list">

                <li @click="$router.push({name:'problem'})">常见问题</li>
                <li @click="$router.push({name:'security'})">安全中心</li>
                <li @click="$router.push({name:'service'})">客服</li>
                <li @click="goLogin">
                    {{ info }}
                </li>
                <li @click="exit">
                    退出
                </li>
            </div>
        </div>

    </div>
</template>

<script>
export default {
    computed: {
        info() {
            // 没有登录时，info是登录，登录以后info是登录的用户名
            return this.$store.state.user_name ? this.$store.state.user_name : '登录';
        },
    },
    methods: {
        goLogin() {
            // 跳转到登录页面  当是用户名时，跳转到个人中心
            if (!this.$store.state.user_name) {
                this.$router.push({
                    name: 'login'
                })
            }else{
                this.$router.push({
                    name: 'personcenter'
                })
            }
        },
        exit() {
            localStorage.clear();
            sessionStorage.clear();
            window.open("about:blank", "_self");
            window.close();
        }
    }
}
</script>

<style lang="scss" scoped>
.head {
    display: flex;
    justify-content: space-between;
    height: 100%;

    .left {
        display: flex;
        align-items: center;

        img {
            width: 60px;
            height: 100%;
            border-radius: 50%;
        }
    }

    .right {
        width: 40%;
        align-items: center;

        .list {
            display: flex;
            justify-content: space-around;
            align-items: center;
           li{
            font-size: 10px;
           }
        }
    }
}
</style>